/*
_3D_Vector.h with _3D_Vector.cpp contains class _3D_Vector
Which is a array contains 3 Type
and support most of operations of vector (in math)
such as plus, minus, multiplied-by-number,
dot-multiply, cross-multiply, unitary
and calculate its length, the angle between two vectors.
See the definition for detail.
Author: NianchenDeng (5080379114)
*/

#pragma once
#define uint unsigned int
#define VType float
#include <math.h>

class _3D_Vector
{
private:
  VType *_Arr;
  mutable double _Length;
  void calc_length () const;
  void assign_value (const VType* coordinate);
  void assign_value (const VType* vertex1, const VType* vertex2);
public:
	_3D_Vector ();
	_3D_Vector (const VType* vertex1, const VType* vertex2);
	_3D_Vector (VType x, VType y, VType z);
	_3D_Vector (const VType* source);
  _3D_Vector (const _3D_Vector& source);
	~_3D_Vector ();

	_3D_Vector& operator= (const _3D_Vector &right);
  _3D_Vector& operator+= (const _3D_Vector& right);
  _3D_Vector& operator-= (const _3D_Vector& right);
  _3D_Vector& operator*= (const VType& right);
  _3D_Vector& operator/= (const VType& right);
  _3D_Vector& unitary ();

	double length () const;
	VType& operator[] (uint pos) const;
	const VType* data () const;

	_3D_Vector operator+ (const _3D_Vector& right) const;
	_3D_Vector operator- (const _3D_Vector& right) const;
	_3D_Vector operator* (const VType& right) const;
	_3D_Vector operator/ (const VType& right) const;
  _3D_Vector operator- () const;
	double dot (const _3D_Vector& right) const;
	_3D_Vector cross (const _3D_Vector& right) const;

	double angle (const _3D_Vector& right) const;
  double distance (const _3D_Vector& right) const;
};